package com.tcreditdemo;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.lang.reflect.Array;
import java.util.ArrayList;

/**
 * Created by xiongzheng on 2018/10/11.
 */

public class MeRecyclerAdapter extends RecyclerView.Adapter<MeRecyclerAdapter.Meholder> {
    private Context context;
    private ArrayList<ArrayList<Integer>> datas=new ArrayList<>();



    public MeRecyclerAdapter(Context context, ArrayList<ArrayList<Integer>> datas) {
        this.context = context;
        this.datas = datas;
    }

    @Override
    public Meholder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.me_adapter_view, parent, false);
        return new Meholder(view);
    }

    @Override
    public void onBindViewHolder(Meholder holder, int position) {
        LinearLayoutManager layoutManager = new LinearLayoutManager(context);
        holder.recyclerView.setLayoutManager(layoutManager);
        MeDetailAdapter adapter = new MeDetailAdapter(datas.get(position));
        holder.recyclerView.setAdapter(adapter);
        adapter.setOnItemClickListener(new MeDetailAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position, String title) {
                ToastUtil.showToastCenter(title);
            }
        });

    }

    @Override
    public int getItemCount() {
        return datas.size();
    }

    class Meholder extends RecyclerView.ViewHolder{
        public RecyclerView recyclerView;

        public Meholder(View itemView) {
            super(itemView);
            recyclerView=itemView.findViewById(R.id.recycler);
        }
    }
}
